Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification regarding Validation.Pattern #254

Closed
wants to merge 1 commit into from

Conversation

HeikoTheissen
Copy link
Contributor

The annotated property must match the regular expression in its entirety, because a regular expression like \d+ (one or more digits) is also matched by the string 7up, just not in its entirety.

Copy link
Contributor

@ralfhandl ralfhandl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current behavior is intended, Validation.Pattern is the counterpart to the JSON Schema keyword pattern, which explicitly states that

regular expressions are not implicitly anchored

If someone wants a prefix, suffix, or full match, they can anchor the regular expression using ^ and $, for example ^\d+$ will only match if the string consists entirely of digits and has a minimum length of 1.

@HeikoTheissen HeikoTheissen deleted the Validation.Pattern branch May 8, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

2 participants